import { NotFoundError } from './NotFoundError'
import { InternalServerError } from './InternalServerError'
import { ForbiddenError } from './ForbiddenError'

interface ErrorInfo {
    message: string;
    i18nMsg?: string;
    data?: Object;
}

export class ErrorHelper {
    static createNotFoundError(info: ErrorInfo): NotFoundError {
        return new NotFoundError(info.message, info.i18nMsg, info.data)
    }

    static createInternalServerError(info: ErrorInfo): InternalServerError {
        return new InternalServerError(info.message, info.i18nMsg, info.data)
    }

    static createForbiddenError(info: ErrorInfo): ForbiddenError {
        return new ForbiddenError(info.message, info.i18nMsg, info.data)
    }

    static throwNotFoundError(info: ErrorInfo) {
        throw ErrorHelper.createNotFoundError(info)
    }

    static throwInternalServerError(info: ErrorInfo) {
        throw ErrorHelper.createInternalServerError(info)
    }

    static throwForbiddenError(info: ErrorInfo) {
        throw ErrorHelper.createForbiddenError(info)
    }

    // static rejectWithNotFoundError(rej: Function, message?: string) {
    //     rej(ErrorHelper.createNotFoundError(message))
    // }

    // static rejectWithInternalServerError(rej: Function, message?: string, friendlyMessage?: string) {
    //     rej(ErrorHelper.createInternalServerError(message))
    // }

    // static rejectWithForbiddenError(rej: Function, message?: string) {
    //     rej(ErrorHelper.createForbiddenError(message))
    // }
}